var ds;
var sn, userSc;
var searchField;
var infoDs;
var infoSm;
function displayManualContent() {
	Ext.form.Field.prototype.msgTarget = 'side';
	Ext.QuickTips.init();
	var siteDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'sites',
			id : 'id',
			fields : [ {
				name : 'id'
			}, {
				name : 'name'
			}, {
				name : 'code'
			} ]
		})
	});
	var siteCombo = new Ext.form.ComboBox({
		id : 'siteCb',
		name : 'siteCb',
		mode : 'local',
		forceSelection : true,
		displayField : 'name',
		valueField : 'code',
		emptyText : '--切换驻地--',
		width : 90,
		triggerAction : 'all',
		selectOnFocus : true,
		triggerClass : 'x-form-trigger2',
		store : siteDs,
		lazyInit : false,
		editable : false
	});
	siteCombo
			.on(
					'select',
					function(combo, record, index) {
						if (record.get('code') == BestvSearch.sc)
							return;
						ds
								.load({
									params : {
										start : 0,
										limit : PAGE_SIZE,
										siteCode : record.get('code')
									},
									callback : function() {
										if (ds.reader.jsonData == '') {
											Ext.MessageBox
													.alert(
															TXT_common_hint,
															TXT_common_relogin,
															function() {
																window.location.href = '../eni/common/logout.jsp';
															});
											return;
										}
									}
								});
						BestvSearch.sc = record.get('code');
						sn = record.get('name');
						if (BestvSearch.sc == 'HDQ') {
							gridCm.setHidden(8, false);
							gridCm.setHidden(9, true);
						} else {
							gridCm.setHidden(8, true);
							gridCm.setHidden(9, false);
						}
					});
	siteDs.baseParams = {
		cmd : 'site',
		action : 'find'
	};
	var btnCreate = new Ext.Button({
		text : TXT_common_create,
		tooltip : TXT_common_create,
		iconCls : 'icoAdd'
	});

	var btnEdit = new Ext.Button({
		text : TXT_common_edit,
		tooltip : TXT_common_edit,
		iconCls : 'icoEdit'
	// disabled:'true'
	});
	var btnDelete = new Ext.Button({
		text : TXT_common_delete,
		tooltip : TXT_common_delete,
		iconCls : 'icoDel'
	});

	btnCreate.on('click', function() {
		createManualFormWin('');
	});

	btnEdit.on('click', function() {
		if (sm.getCount() == 0) {
			Ext.MessageBox.alert(TXT_common_hint, TXT_user_need);
			return;
		}
		var record = sm.getSelected();
		createManualFormWin(record);
	});
	btnDelete
			.on(
					'click',
					function() {
						if (sm.getCount() == 0) {
							Ext.MessageBox
									.alert(TXT_common_hint, TXT_user_need);
							return;
						}
						var record = sm.getSelected();
						Ext.MessageBox
								.confirm(
										TXT_common_hint,
										TXT_user_delete_confirmation,
										function(btn) {
											if (btn == 'yes') {
												BestvSearch.showWaitingWin();
												Ext.Ajax
														.request({
															url : DISPATCH_URL,
															method : 'POST',
															params : 'cmd=manualBind&action=delete&id='
																	+ record.id
																	+ '&sc='
																	+ BestvSearch.sc,
															success : function(
																	response,
																	options) {
																Ext.MessageBox
																		.hide();
																var s = response.responseText;
																if (s == '[error]') {
																	Ext.MessageBox
																			.alert(
																					TXT_common_hint,
																					TXT_common_access_fail);
																} else if (s == '[null]') {
																	Ext.MessageBox
																			.alert(
																					TXT_common_hint,
																					TXT_common_relogin,
																					function() {
																						window.location.href = LOGIN_URL;
																					});
																} else {
																	var result = Ext.util.JSON
																			.decode(s);
																	if (result.result == 'success') {
																		ds
																				.load({
																					params : {
																						start : 0,
																						limit : PAGE_SIZE,
																						siteCode : BestvSearch.sc
																					}
																				});
																	} else if (result.message == 'idnull') {
																		Ext.MessageBox
																				.hide();
																		Ext.MessageBox
																				.alert(
																						TXT_common_hint,
																						TXT_common_id_null);
																	}
																}
															},
															failure : function(
																	response,
																	options) {
																Ext.MessageBox
																		.hide();
																Ext.MessageBox
																		.alert(
																				TXT_common_hint,
																				TXT_common_access_fail);
															}
														});
											}
										});
					});
	var sm = new Ext.grid.RowSelectionModel({
		singleSelect : true
	});
	ds = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'manualBinds',
			id : 'id',
			fields : [ {
				name : 'id'
			}, {
				name : 'name'
			}, {
				name : 'creator'
			}, {
				name : 'createTime'
			}, {
				name : 'tags'
			}, {
				name : 'sites'
			}, {
				name : 'owner'
			}, {
				name : 'failed'
			}, {
				name : 'startTime'
			}, {
				name : 'endTime'
			}, {
				name : 'programs'
			} ]
		})
	});
	var gridCm = new Ext.grid.ColumnModel([
			new Ext.grid.RowNumberer(),
			{
				header : '名称',
				dataIndex : 'name',
				width : 95,
				renderer : function(v) {
					if (v.length > 5)
						return '<div qtip=' + v + '>' + v.substring(0, 4)
								+ '..</div>';
					return v;
				}
			},
			{
				header : TXT_creator,
				dataIndex : 'creator',
				width : 105,
				renderer : function(v) {
					if (v.length > 7)
						return '<div qtip=' + v + '>' + v.substring(0, 7)
								+ '</div>';
					return v;
				}
			},
			{
				header : TXT_createTime,
				dataIndex : 'createTime',
				width : 75,
				sortable : true,
				renderer : function(v) {
					return v.substring(2);
				}
			},
			{
				header : TXT_manual_tags,
				dataIndex : 'tags',
				width : 175,
				renderer : function(v) {
					if (v.length > 7)
						return '<div qtip=' + v + '>' + v.substring(0, 7)
								+ '</div>';
					return v;
				}
			},
			{
				header : TXT_manual_start_time,
				dataIndex : 'startTime',
				width : 115,
				renderer : function(v) {
					return v.substring(2);
				}
			},
			{
				header : TXT_manual_end_time,
				dataIndex : 'endTime',
				width : 115,
				renderer : function(v) {
					return v.substring(2);
				}
			},
			{
				header : '是否生效',
				dataIndex : 'failed',
				width : 88,
				sortable : true,
				renderer : function(v) {
					if (v == 1)
						return "<span style='color:#DF0101'>未生效</span>";
					if (v == 2)
						return "<span style='color:blue'>已生效</span>";
					if (v == 3)
						return "<span style='color:#8A0808'>已过期</span>";
					if (v != '')
						return "<span style='color:#DF0101'>" + v + "</span>";
					return "<span style='color:blue'>均已生效</span>";
				}
			},
			{
				header : '驻地',
				dataIndex : 'sites',
				width : 130,
				renderer : function(value, metadata, record) {
					if (value == '')
						return;
					var cb_cns = value.split('&');
					if (cb_cns.length != 2)
						return;
					var cbs = cb_cns[0].trim().split(/ +/);
					var cns = cb_cns[1].trim().split(/ +/);
					if (cbs.length != cns.length)
						return;
					var rt = '';
					for ( var k = 0; k < cbs.length; ++k) {
						if (cbs[k] != '' && cns[k] != '')
							rt += '<a HREF="javascript:lookUpBindinfos('
									+ record.id + ',\'' + cns[k] + '\',\''
									+ cbs[k] + '\')">' + cns[k] + '</a>';
						rt += '   ';
					}
					return rt;
				}
			},
			{
				header : TXT_bind_programs,
				dataIndex : 'programs',
				width : 40,
				renderer : function(value, metadata, record) {
					return '<a HREF="javascript:lookUpBindinfos(' + record.id
							+ ',\'' + sn + '\',\'' + BestvSearch.sc
							+ '\')">查看</a>';
				}
			} ]);
	var grid = new Ext.grid.GridPanel(
			{
				el : 'grid',
				ds : ds,
				cm : gridCm,
				sm : sm,
				viewConfig : {
					forceFit : true
				},
				stripeRows : true,
				loadMask : true,
				title : TXT_manual_title,
				tbar : [ btnCreate, '-', btnEdit, '-', btnDelete, '->',
						siteCombo, '-' ],
				bbar : new Ext.PagingToolbar({
					pageSize : PAGE_SIZE,
					store : ds,
					displayInfo : true,
					displayMsg : TXT_common_paging,
					emptyMsg : TXT_common_no
				})
			});
	grid.on('click', function() {
		if (sm.getCount() == 0)
			return;
		var record = sm.getSelected();
		if (userSc == 'HDQ') {
			if (BestvSearch.sc == 'HDQ') {
				btnEdit.setDisabled(false);
				btnDelete.setDisabled(false);
			} else if (record.get('owner') != BestvSearch.sc) {
				btnEdit.setDisabled(true);
				btnDelete.setDisabled(true);
			} else {
				btnEdit.setDisabled(false);
				btnDelete.setDisabled(false);
			}
		} else if (record.get('creator').indexOf('总部') >= 0) {
			btnEdit.setDisabled(true);
			btnDelete.setDisabled(true);
		} else {
			btnEdit.setDisabled(false);
			btnDelete.setDisabled(false);
		}
	});
	ds.baseParams = {
		cmd : 'manualBind',
		action : 'find'
	};
	ds.on('load', function() {
		grid.getSelectionModel().selectFirstRow();
		if (sm.getCount() == 0)
			return;
		var record = sm.getSelected();
		if (userSc == 'HDQ') {
			if (BestvSearch.sc == 'HDQ') {
				btnEdit.setDisabled(false);
				btnDelete.setDisabled(false);
			} else if (record.get('owner') != BestvSearch.sc) {
				btnEdit.setDisabled(true);
				btnDelete.setDisabled(true);
			} else {
				btnEdit.setDisabled(false);
				btnDelete.setDisabled(false);
			}
		} else if (record.get('creator').indexOf('总部') >= 0) {
			btnEdit.setDisabled(true);
			btnDelete.setDisabled(true);
		} else {
			btnEdit.setDisabled(false);
			btnDelete.setDisabled(false);
		}
	});
	BestvSearch.glb_mainPanel.add(grid);
	BestvSearch.drawMainFrame(TXT_app_name + ' - ' + TXT_manual_title, siteDs);
	siteDs.on('load', function(store, records, options) {
		if (BestvSearch.sc == 'HDQ') {
			gridCm.setHidden(8, false);
			gridCm.setHidden(9, true);
		} else {
			gridCm.setHidden(8, true);
			gridCm.setHidden(9, false);
		}
		sn = records[0].get('name');
		if (records.length == 1)
			userSc = records[0].get('code');
		else
			userSc = 'HDQ';
		// if(BestvSearch.sc != 'HDQ'){
		siteCombo.setValue(BestvSearch.sc);
		ds.load({
			params : {
				start : 0,
				limit : PAGE_SIZE,
				siteCode : BestvSearch.sc
			}
		});
		// }
	});
}

function createManualFormWin(record) {
	var mid = '';
	var sc = BestvSearch.sc;
	if (record != '') {
		// if(userSc == 'HDQ'){
		// if(BestvSearch.sc == 'HDQ'){
		// }else if(record.get('owner') != BestvSearch.sc){
		// Ext.MessageBox.alert(TXT_common_hint,'对不起，该记录为全局创建，请在页面右上角选择"总部"进行全局范围修改！');
		// return;
		// }
		// }else if(record.get('creator').indexOf('总部') >= 0){
		// Ext.MessageBox.alert(TXT_common_hint,'对不起，该记录是由总部管理人员创建的，您没有修改权限！');
		// return;
		// }
		// alert(sc == BestvSearch.sc); //always true
		// sc = record.get('owner');
		mid = record.id;
	}
	infoDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'infos',
			totalProperty : 'totalCount',
			id : 'id',
			fields : [ {
				name : 'id'
			}, {
				name : 'name'
			}, {
				name : 'code'
			}, {
				name : 'type'
			}, {
				name : 'keywords'
			}, {
				name : 'tags'
			}, {
				name : 'updateTime'
			}, {
				name : 'description'
			} ]
		})
	});
	infoDs.on('load', function() {
		infoSm.selectAll();
	});
	var siteDs2 = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'sites',
			id : 'id',
			fields : [ {
				name : 'id'
			}, {
				name : 'name'
			}, {
				name : 'code'
			} ]
		})
	});
	siteDs2.baseParams = {
		cmd : 'site',
		action : 'findExpHDQ'
	};
	var siteCombo2 = new Ext.form.MultiComboBox({
		id : 'siteCombo2',
		name : 'siteCombo2',
		displayField : "name",
		valueField : 'code',
		labelSeparator : '：',
		displaySeparator : ';',
		valueSeparator : ',',
		mode : 'local',
		forceSelection : true,
		hiddenName : 'test',
		store : siteDs2,
		editable : false,
		triggerAction : 'all',
		allowBlank : false,
		emptyText : '支持多选...',
		fieldLabel : '选择驻地'
	});
	siteDs2.on('load', function() {
		if (siteDs2.getCount() == 1) {
			siteCombo2.setValue(siteDs2.getAt(0).get('code'));
			siteCombo2.setDisabled(true);
		} else if (BestvSearch.sc != 'HDQ') {
			siteCombo2.setValue(BestvSearch.sc);
			siteCombo2.setDisabled(true);
		}
	});
	siteDs2.load({
		callback : function(r, options, success) {
			if (siteDs2.reader.jsonData == '') {
				Ext.MessageBox.alert(TXT_common_hint, TXT_common_relogin,
						function() {
							window.location.href = '../eni/common/logout.jsp';
						});
				return;
			}
		}
	});
	infoSm = new Ext.grid.CheckboxSelectionModel();
	var infoCm = new Ext.grid.ColumnModel([
			new Ext.grid.RowNumberer(),
			infoSm,
			{
				header : TXT_info_name,
				dataIndex : 'name',
				width : 230,
				renderer : function(v) {
					if (v.length > 12)
						return '<div qtip=' + v + '>' + v.substring(0, 12)
								+ '..</div>';
					return v;
				}
			},
			{
				header : TXT_info_code_url,
				dataIndex : 'code',
				width : 240,
				renderer : function(v) {
					if (v.indexOf('@') >= 0)
						return '<div qtip=' + v + '>'
								+ v.replace('BESTV.SMG.SMG', '...') + '</div>';
					return v;
				}
			},
			{
				header : TXT_info_type,
				dataIndex : 'type',
				width : 70,
				renderer : function(v) {
					if (v.length > 5)
						return '<div qtip=' + v + '>' + v.substring(0, 5)
								+ '..</div>';
					return v;
				}
			},
			{
				header : 'keywords',
				dataIndex : 'keywords',
				width : 200,
				renderer : function(v) {
					if (v.length > 7)
						return '<div qtip=' + v + '>' + v.substring(0, 7)
								+ '..</div>';
					return v;
				}
			},
			{
				header : TXT_entrance_tags,
				dataIndex : 'tags',
				width : 200,
				renderer : function(v) {
					if (v.length > 7)
						return '<div qtip=' + v + '>' + v.substring(0, 7)
								+ '..</div>';
					return v;
				}
			}, {
				header : TXT_info_update_time,
				dataIndex : 'updateTime',
				width : 100
			}, {
				header : TXT_info_description,
				dataIndex : 'description',
				width : 120,
				renderer : function(v) {
					return "<div ext:qtip='" + v + "'>...</div>";
				}
			} ]);
	var infoGrid = new Ext.grid.GridPanel({
		border : false,
		region : 'center',
		ds : infoDs,
		cm : infoCm,
		sm : infoSm,
		stripeRows : true,
		loadMask : true,
		title : TXT_bind_info,
		viewConfig : {
			forceFit : true
		},
		bbar : new Ext.PagingToolbar({
			pageSize : PAGE_SIZE,
			store : infoDs,
			displayInfo : true,
			displayMsg : TXT_common_paging,
			emptyMsg : TXT_common_no
		})
	});
	searchField = new Ext.app.SearchField({
		anchor : '90%',
		fieldLabel : TXT_manual_info_search
	});
	var manualForm = new Ext.FormPanel({
		labelAlign : 'right',
		region : 'north',
		labelWidth : 80,
		height : 120,
		frame : true,
		items : [ {
			layout : 'column',
			items : [ {
				columnWidth : .5,
				layout : 'form',
				defaultType : 'textfield',
				defaults : {
					anchor : '90%'
				},
				items : [ {
					fieldLabel : TXT_manual_name,
					id : 'manualName',
					name : 'manualName',
					allowBlank : false
				}, new Ext.form.DateField({
					fieldLabel : TXT_manual_start_time,
					id : 'validDate',
					name : 'validDate',
					format : 'Y-m-d G:i',
					allowBlank : false
				}) ]
			}, {
				columnWidth : .5,
				layout : 'form',
				defaultType : 'textfield',
				defaults : {
					anchor : '91%'
				},
				items : [ siteCombo2, new Ext.form.DateField({
					fieldLabel : TXT_manual_end_time,
					id : 'invalidDate',
					name : 'invalidDate',
					format : "Y-m-d G:i",
					allowBlank : false
				}) ]
			} ]
		}, {
			layout : 'form',
			defaultType : 'textfield',
			defaults : {
				anchor : '95%'
			},
			items : [ {
				fieldLabel : TXT_manual_tags,
				id : 'tags',
				name : 'tags',
				emptyText : 'tag之间请用空格隔开...',
				allowBlank : false
			} ]
		}, searchField ]
	});
	var mwin = null;
	if (!mwin) {
		mwin = new Ext.Window(
				{
					title : TXT_maunal_bind,
					width : 500,
					height : 350,
					autoScroll : false,
					layout : 'border',
					border : false,
					minimizable : false,
					maximizable : true,
					resizable : true,
					modal : true,
					layoutConfig : {
						animate : false
					},
					items : [ manualForm, infoGrid ],
					tbar : [
							new Ext.Button(
									{
										text : TXT_common_save,
										iconCls : 'icoOK',
										handler : function() {
											if (!manualForm.form.isValid())
												return;
											var manualName = manualForm
													.findById('manualName')
													.getValue();
											var validDate = Ext.util.Format
													.date(manualForm.findById(
															'validDate')
															.getValue(),
															'Y-m-d G:i');
											var invalidDate = Ext.util.Format
													.date(manualForm.findById(
															'invalidDate')
															.getValue(),
															'Y-m-d G:i');
											if (validDate == '') {
												Ext.MessageBox.alert(
														TXT_common_hint,
														'请填写生效时间');
												return;
											}
											if (invalidDate == '') {
												Ext.MessageBox.alert(
														TXT_common_hint,
														'请填写失效时间');
												return;
											}
											if (manualForm.findById(
													'invalidDate').getValue() <= manualForm
													.findById('validDate')
													.getValue()) {
												Ext.MessageBox.alert(
														TXT_common_hint,
														'失效时间必须大于生效时间');
												return;
											}
											var site = siteCombo2.hiddenField.value; // just
											// get
											// the
											// value
											// which
											// was
											// set
											// manual
											if (site == '')
												site = siteCombo2.getValue();// Can
											// get
											// the
											// value
											// which
											// was
											// set
											// by
											// ExtJS
											// Code
											// siteCombo2.setValue(v);
											var tags = manualForm.findById(
													'tags').getValue();
											// var infoIds = "";
											var infoCodes = "";
											var infoRecords = infoSm
													.getSelections();
											for ( var i = 0; i < infoRecords.length; ++i)
												// infoIds += "&infoId=" +
												// infoRecords[i].get("id")
												infoCodes += "&infoCode="
														+ infoRecords[i]
																.get("code");
											BestvSearch.showWaitingWin();
											Ext.Ajax
													.request({
														url : DISPATCH_URL,
														method : 'post',
														params : 'cmd=manualBind&action=save&id='
																+ mid
																+ '&name='
																+ manualName
																+ '&vdate='
																+ validDate
																+ '&invdate='
																+ invalidDate
																+ '&tags='
																+ tags
																+ infoCodes
																+ '&sc='
																+ site
																+ '&globleSC='
																+ BestvSearch.sc,
														success : function(
																response,
																options) {
															Ext.MessageBox
																	.hide();
															var s = response.responseText;
															if (s == '[error]') {
																Ext.MessageBox
																		.alert(
																				TXT_common_hint,
																				TXT_common_access_fail);
															} else if (s == '[null]') {
																Ext.MessageBox
																		.alert(
																				TXT_common_hint,
																				TXT_common_relogin,
																				function() {
																					window.location.href = '../eni/common/logout.jsp';
																				});
															} else if (s == '[existed]') {
																Ext.MessageBox
																		.alert(
																				TXT_common_hint,
																				'相同名字的人工绑定已经存在');
															} else {
																var result = Ext.util.JSON
																		.decode(s);
																if (result.result == 'success') {
																	mwin
																			.close();
																	ds
																			.load({
																				params : {
																					start : 0,
																					limit : PAGE_SIZE,
																					siteCode : sc
																				}
																			});
																}
															}
														}
													});
										}
									}), '-', new Ext.Button({
								text : TXT_common_cancel,
								handler : function() {
									mwin.close();
								}
							}) ]
				});
	}
	mwin.on('show', function() {
		mwin.maximize();
		if (mid != '') {
			infoDs.baseParams = {
				cmd : 'search',
				action : 'searchInfoByManualId'
			};
			infoDs.load({
				params : {
					start : 0,
					limit : PAGE_SIZE,
					manualId : mid,
					siteCode : sc,
					acs_type : 'manual'
				}
			});
			Ext.Ajax
					.request({
						url : DISPATCH_URL,
						method : 'post',
						params : 'cmd=manualBind&action=get&id=' + mid + '&sc='
								+ sc,
						success : function(response, options) {
							var s = response.responseText;
							if (s == '[error]')
								Ext.MessageBox.alert(TXT_common_hint,
										TXT_common_access_fail);
							else if (s == '[null]') {
								Ext.MessageBox.alert(TXT_common_hint,
										TXT_common_relogin, function() {
											window.location.href = LOGIN_URL;
										});
							} else {
								var result = Ext.util.JSON.decode(s);
								manualForm.findById('manualName').setValue(
										result.name);
								manualForm.findById('validDate').setValue(
										result.startDate);
								manualForm.findById('invalidDate').setValue(
										result.endDate);
								manualForm.findById('siteCombo2').setValue(
										result.sites);
								manualForm.findById('siteCombo2').setDisabled(
										true);
								manualForm.findById('tags').setValue(
										result.tags);
								infoDs.l;
							}
						},
						failure : function(response, options) {
							Ext.MessageBox.alert(TXT_common_hint,
									TXT_common_access_fail);
						}
					});
		}
	});
	mwin.show();
}
function lookUpBindinfos(mid, sn, sc) {
	var bindInfoDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'infos',
			id : 'id',
			effect : 'effect',
			fields : [ {
				name : 'id'
			}, {
				name : 'name'
			}, {
				name : 'type'
			}, {
				name : 'p_type'
			}, {
				name : 'updateTime'
			}, {
				name : 'keywords'
			}, {
				name : 'existed'
			}, {
				name : 'tags'
			}
			// {name: 'actors'},
			// {name: 'directors'}
			]
		})
	});
	bindInfoDs.baseParams = {
		cmd : 'manualBind',
		action : 'findBindInfosByMbId'
	};
	var bindInfoSm = new Ext.grid.RowSelectionModel({
		singleSelect : true
	});
	var bindInfoCm = new Ext.grid.ColumnModel([
			new Ext.grid.RowNumberer(),
			{
				header : TXT_info_name,
				dataIndex : 'name',
				width : 200,
				renderer : function(v) {
					if (v.length > 12)
						return "<div ext:qtip='" + v + "'>"
								+ v.substring(0, 12) + "..</div>";
					return v;
				}
			},
			{
				header : TXT_info_type,
				dataIndex : 'type',
				width : 60,
				renderer : function(v) {
					if (v.length > 3)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 3)
								+ "..</div>";
					return v;
				}
			},
			{
				header : TXT_info_p_type,
				dataIndex : 'p_type',
				width : 74,
				renderer : function(v) {
					if (v.length > 4)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 4)
								+ "..</div>";
					return v;
				}
			},
			{
				header : '更新时间',
				dataIndex : 'updateTime',
				width : 98,
				renderer : function(v) {
					return "<div ext:qtip='" + v + "'>" + v.substring(2)
							+ "</div>";
				}
			},
			{
				header : '关键字',
				dataIndex : 'keywords',
				width : 200,
				renderer : function(v) {
					if (v.length > 10)
						return "<div ext:qtip='" + v + "'>"
								+ v.substring(0, 10) + "..</div>";
					return v;
				}
			},
			{
				header : '标签',
				dataIndex : 'tags',
				width : 200,
				renderer : function(v) {
					if (v.length > 10)
						return "<div ext:qtip='" + v + "'>"
								+ v.substring(0, 10) + "..</div>";
					return v;
				}
			} ]);
	var bindInfoGrid = new Ext.grid.GridPanel({
		border : true,
		region : 'center',
		ds : bindInfoDs,
		cm : bindInfoCm,
		sm : bindInfoSm,
		stripeRows : true,
		loadMask : true,
		viewConfig : {
			forceFit : true,
			getRowClass : function(record, rowIndex, rowParams, store) {
				if (record.get('existed') == 'n')
					return 'x-grid-record-red';
				else
					return '';
			}
		}
	});
	var t_panel = new Ext.Panel(
			{
				region : 'north',
				border : false,
				split : false,
				height : 35,
				collapsible : false,
				autoScroll : false,
				html : '<div><table><tr style="height:8px"><td colspan=2></td></tr><tr><td style="width:10px"></td><td id="total_msg"></td></tr><tr style="height:5px"><td colspan=2></td></tr></table></div>'
			});
	var bwin = null;
	if (!bwin) {
		bwin = new Ext.Window({
			title : '绑定信息明细',
			width : document.body.clientWidth * 0.8,
			height : document.body.clientHeight * 0.75,
			autoScroll : false,
			layout : 'border',
			border : false,
			minimizable : false,
			maximizable : true,
			resizable : true,
			buttonAlign : 'center',
			modal : true,
			layoutConfig : {
				animate : false
			},
			items : [ bindInfoGrid, t_panel ],
			buttons : [ {
				text : TXT_common_close,
				handler : function() {
					bwin.close();
				}
			} ]
		});
	}
	bwin.show();
	bindInfoDs.on('load', function(store, records, options) {
		if (sc == 'HDQ') {
			bwin.remove(t_panel);
			t_panel.destroy();
			bwin.doLayout();
		} else if (store.reader.jsonData.effect == 'noBindInfo') {
			document.getElementById('total_msg').style.color = 'green';
			document.getElementById('total_msg').style.fontSize = '16px';
			document.getElementById('total_msg').style.fontWeight = 'bold';
			document.getElementById('total_msg').innerHTML = '尚未有信息绑定！';
		} else if (store.reader.jsonData.effect == 'n') {
			document.getElementById('total_msg').style.color = 'red';
			document.getElementById('total_msg').style.fontSize = '16px';
			document.getElementById('total_msg').style.fontWeight = 'bold';
			document.getElementById('total_msg').innerHTML = '红色字体的信息在驻地 "'
					+ sn + '" 尚未存在！';
		} else {
			document.getElementById('total_msg').style.color = 'blue';
			document.getElementById('total_msg').style.fontSize = '16px';
			document.getElementById('total_msg').style.fontWeight = 'bold';
			document.getElementById('total_msg').innerHTML = '以下信息在驻地 "' + sn
					+ '"已全部绑定！';
		}
	});
	bindInfoDs.load({
		params : {
			sc : sc,
			id : mid
		}
	});
}
Ext.onReady(displayManualContent);